﻿//********************************************************************************//
//创建日期：<创建日期，2016-05-11>
//创建作者：<郭登杰>
//功能说明：来函流程公共控件-右侧上部信息2
//********************************************************************************//
using DevExpress.Web;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BLL;
using BLL.Access;
using Platform.Http;
using Web.Class;
using Platform.Common;
using DevExpress.Web;
using System.Text;

namespace Web.Controls.LAIHAN
{
    public partial class UCLHLCTOPINFO2 : System.Web.UI.UserControl,IUCLHOperate
    {
        #region 属性

        /// <summary>
        /// 来函类型
        /// </summary>
        public eLaiHanLX LaiHanLX
        {
            get;
            set;
        }

        /// <summary>
        /// 来函流程
        /// </summary>
        public eLaiHanLCBH LaiHanLC { get; set; }

        #endregion

        #region 变更

        private SpHelper _sphelper = new SpHelper();

        #endregion

        #region 事件

        /// <summary>
        /// 加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitControl();
            }
        }

        #endregion

        #region 方法

        /// <summary>
        /// 配置控件
        /// </summary>
        public void InitControl()
        {            
            this.txtShouLiRQ.Enabled = false;
            this.txtXingZhengXKSLBH.Enabled = false;
            this.txtXingZhengXKBH.Enabled = false;
            this.txtTongYiSPBH.Enabled = false;
            this.txtYeWuY.Enabled = false;
            this.txtYongHuM.Enabled = false;
            if (this.LaiHanLX == eLaiHanLX.销户 || this.LaiHanLX == eLaiHanLX.销表 || this.LaiHanLX == eLaiHanLX.退款)
            {
                this.tdXingZhengXKH1.Visible = false;
                this.tdXingZhengXKH2.Visible = false;
                this.tdXuKeSL1.Visible = false;
                this.tdXuKeSL2.Visible = false;
            }
        }

        /// <summary>
        /// 提交验证
        /// </summary>
        /// <returns></returns>
        public ValidateRS Validate()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 清除信息
        /// </summary>
        public void ClearInfo()
        {
            this.txtShouLiRQ.Text = "";
            this.txtXingZhengXKSLBH.Text = "";
            this.txtYeWuY.Text = "";
            this.txtYongHuM.Text = "";
        }

        /// <summary>
        /// 根据来函加载信息
        /// </summary>
        /// <param name="laihanxx">来函信息</param>
        public void LoadInfo(YS_LH_LAIHANXX laihanxx)
        {
            DataRow dr = this._sphelper.P_YS_LHGETINFODETAIL(laihanxx.S_LAIHANBH,(int)laihanxx.I_LAIHANLX).Tables[0].Rows[0];
            this.txtShouLiRQ.Text=Convert.ToDateTime(dr["D_SHOULIRQ"]).ToString("yyyy-MM-dd");
            this.txtXingZhengXKSLBH.Text = dr["S_XUKEBH"].ToString();
            //this.txtXingZhengXKBH.Text=dr["S_TONGYIBM"].ToString();
            this.txtTongYiSPBH.Text = dr["S_TONGYIBM"].ToString();
            this.txtYeWuY.Text = dr["S_YWY"].ToString();
            this.txtYongHuM.Text = dr["s_yonghum"].ToString();
            this.txtYongHuH.Text = dr["s_yonghubh"].ToString();
            // 定额计算
            btnDinge.Visible = false;
            if ((int)laihanxx.I_LAIHANLX == (int)eLaiHanLX.年度)
            {
                var drc = new YS_YG_YONGHUXXBLL().SelectYS_YG_YONGHUXXesDynamic(" I_LEIXING=0 and S_YONGHUH='" + txtYongHuH.Text + "' ", null);
                string sSsdx = drc.Rows[0]["S_SHESHUIDXDM"].ToString();
                if (sSsdx.Length >= 4) sSsdx = sSsdx.Substring(0, 3);
                if ("413" == sSsdx || "414" == sSsdx || "415" == sSsdx || "416" == sSsdx)
                {
                    btnDinge.Visible = true;
                    btnDinge.Text = "学校定额计算表";
                }
                else if ("417" == sSsdx)
                {
                    btnDinge.Visible = true;
                    btnDinge.Text = "医院定额计算表";
                }
                if ("406" == sSsdx || "407" == sSsdx)
                {
                    btnDinge.Visible = true;
                    btnDinge.Text = "宾馆定额计算表";
                }
            }
        }

        #endregion               
    }
}